package homework41;

public class Client {
    public static void main(String[] args) {
        Context context = new Context();
        //变量赋值

        context.addValue("a",5);
        context.addValue("b",6);
        context.addValue("c",7);

        //创建变量
        Variable a = new Variable("a");
        Variable b = new Variable("b");
        Variable c = new Variable("c");

        // a×b
        AbstractExpression multiplyValue = new Multiply(a, b);
        // a-b+c
        AbstractExpression addValue = new Add(new Subtract(a, b), c);
        // (a*b)/(a-b+c)
        AbstractExpression divisionValue = new Division(multiplyValue, addValue);

        System.out.println(context.getValueMap());//输出传入的变量值....
        System.out.println(divisionValue.interpreter(context));//(a*b)/(a-b+c)
        System.out.println(addValue.interpreter(context));//a-b+c
        System.out.println(multiplyValue.interpreter(context));//a×b
    }
}
